<template>
	<view style="padding: 30rpx;">
		<view> 
		   <text style="color: #4CD964;">你需要发送验证申请，等对方通过</text>
		</view>
		
		<view>
		   <input class="underline" placeholder="" v-bind:value="reason"/>
		</view>
	</view>
</template>

<script>
	import http from '../../../common/request.js'	
	export default {
		onLoad(options){
				this.uid=options.uid,
				this.getMyName()
		},
		data() {
			return {
			   reason:'我是'	,
			   uid:undefined
			}
		},
		methods: {
			onNavigationBarButtonTap:function(e){
				
				if('发送'===e.text){
					this.addFriend(this.uid)
				}
			},
			getMyName(){
				this.reason = '我是'+uni.getStorageSync('userKey').name
			},
			async addFriend(uid) {
					const res = await http.request({
						url: '/sys_friends/add_friend',
						method:'POST',
						data:{friendId:uid,reason:this.reason}
					})
					if(res.data.code==0){
						uni.switchTab({
							url:'/pages/index/contacts/contacts'
						})
					}else{
						uni.showToast({
							title:res.data.data.message
						})
					}				
			},
		}
	}
</script>

<style>
.underline {
    border-bottom: 1px solid #dbdbdb;
    border-top: 0px;
    border-left: 0px;
    border-right: 0px;
}
</style>
